<?php
/**
 * $Id: tags.php 71 2008-12-25 07:28:33Z gpo_gigapromoters $
 * 
 * This file can not be redistributed to anyone without the permission of Giga Promoters
 * Copyright 2005 - 2008, Giga Promoters
 * 						  608 Aggarwal Cyber Plaza
 *						  Netaji Subhash Place, Delhi - 110034
 *						  www.gigapromoters.com
 * 
 *
 * This is parent of parent class of a controller and should not be edited ever without permission.
 * @version 			$Rev: 71 $
 * @lastModifiedBy		$LastChangedBy: gpo_gigapromoters $
 * @lastChanged			$Date: 2008-12-25 12:58:33 +0530 (Thu, 25 Dec 2008) $
 * @copyright 			Giga Promoters (www.gigapromoters.com)
 * 
 */

/**
 * Tags helper. It should not belong here. 
 * If it has depedency somewhere. Please contact me. This needs to be deleted
 *
 */

class TagsHelper extends AppHelper {

	var $helpers = array('Html');

	function show($tags, $type, $delimiter=', ')
	{
		$outString = '';
		foreach($tags as $tag)
		{
			$link = $this->getLink($tag['tag'], $type);
			$outString .= $link.$delimiter;
		}

		// to remove un-necessary delimiter from end
		$endChars = (-1)*strlen($delimiter);
		$outString = substr($outString, 0, $endChars);

		return $outString;
	}

	function getLink($tag, $type)
	{
		$tagLink = Inflector::slug($tag, '-');
		return $this->Html->link($tag, '/tags/'.$type.'/'.$tagLink);
	}




}
?>